import pymysql

connection = pymysql.connect(host='localhost', user='root', password='123456', db='test')
cursor = connection.cursor()
#cursor.execute("SELECT * FROM teachers")
#cursor.execute("SELECT * FROM teachers WHERE name = %s",['孙老师'])
cursor.execute("SELECT * FROM teachers WHERE name = %(name)s",{'name':'孙老师'})
print(cursor.fetchall())
cursor.close()
connection.close()
